const fs = require('fs');
const path = require('path');

// 读取文件路径，返回读取到的内容
function getFileByPath(fpath,callback){
    fs.readFile( fpath, 'utf-8' , ( err , dataStr )  => {
        // if ( err ) throw err 
        if (err) return callback(err)
        // console.log( dataStr )
        // return dataStr
        callback( null,dataStr );
    })
}


/* var result = getFileByPath( path.join(__dirname, './files/1.text') );
console.log( result ); */

getFileByPath(path.join(__dirname,'./files/4.text'),(err,dataStr)=>{
    if (err) return console.log( err.message )
    console.log( dataStr );
});

